package com.bite.system.domain.question;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bite.common.core.domain.BaseEntity;
import com.bite.system.domain.question.dto.QuestionAddDTO;
import com.bite.system.domain.question.dto.QuestionEditDTO;
import com.bite.system.domain.question.es.QuestionES;
import com.bite.system.domain.question.vo.QuestionDetailVO;
import com.bite.system.domain.question.vo.QuestionVO;
import lombok.Getter;
import lombok.Setter;

/**
 * @TableName tb_question
 */
@TableName(value = "tb_question")
@Getter
@Setter
public class Question extends BaseEntity {
    @TableId(type = IdType.ASSIGN_ID)
    private Long questionId;

    private String title;

    private Integer difficulty;

    private String content;

    private Integer timeLimit;

    private Integer spaceLimit;

    private String questionCase;

    private Long questionHot;

    private String defaultCode;

    private String mainFunc;

    public static Question creatByDTO(QuestionAddDTO questionAddDTO) {
        Question question = new Question();
        BeanUtil.copyProperties(questionAddDTO, question);
        return question;
    }

    public static Question creatByDTO(QuestionEditDTO questionEditDTO) {
        Question question = new Question();
        BeanUtil.copyProperties(questionEditDTO, question);
        return question;
    }

    public QuestionDetailVO toDetailVO() {
        QuestionDetailVO detailVO = new QuestionDetailVO();
        BeanUtil.copyProperties(this, detailVO);
        return detailVO;
    }

    public QuestionES toES() {
        QuestionES questionES = new QuestionES();
        BeanUtil.copyProperties(this, questionES);
        return questionES;
    }
}
